cmake_minimum_required(VERSION 3.0)


## 可执行文件路径
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_FW_OUTPUT_DIRECTORY      "${CMAKE_BINARY_DIR}/out")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/libs")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out/libs")

# 编译相关
## 编译器
set(CMAKE_C_COMPILER "gcc" CACHE INTERNAL "c compiler")
set(CMAKE_CXX_COMPILER "g++" CACHE INTERNAL "cxx compiler")

# 设置 C 编译器选项
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
# 设置 C++ 编译器选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")

# 配置一些路径
## lwip
set(LWIP_PORT_DIR ${CMAKE_CURRENT_LIST_DIR}/lwip_port)
set(LWIP_CORE_DIR ${CMAKE_CURRENT_LIST_DIR}/lwip-2.2.0)
set(LWIP_PORT_INC_PUB
                ${LWIP_PORT_DIR}/include)
message("lwip include LWIP_PORT_DIR: ${LWIP_PORT_DIR}")
message("lwip include LWIP_PORT_INC_PUB: ${LWIP_PORT_INC_PUB}")

set(LWIP_CORE_INC_PUB 
                ${LWIP_CORE_DIR}/src/include
                ${LWIP_CORE_DIR}/src/include/compat/posix)

set(LWIP_NETIF_LINUX_INC_PUB
                ${LWIP_NETIF_LINUX_DIR}/include)

set(LWIP_INC_PUB
                ${LWIP_PORT_INC_PUB}
                ${LWIP_CORE_INC_PUB}
                ${LWIP_NETIF_LINUX_INC_PUB}
                ${CMAKE_SOURCE_DIR}/include)

set(LZM_ALL_LIBS "" CACHE INTERNAL "lzm all libs")

set(target "lzm_lwip")

project(${target})

# src
set(src
    lzm_main.c
    lzm_demo_lwip_netif_linux.c
)

# 添加可执行文件，并指定源文件
add_executable(${target} ${src})

# target_link_options(${target} PRIVATE -T ${CMAKE_CURRENT_SOURCE_DIR}/lzm_link.ld)
target_link_libraries(${target} PUBLIC pthread lzm_lwipcore lzm_lwipport lzm_lwipnetif_linux lzm_apps)

add_subdirectory(log)
add_subdirectory(lwip_port)
add_subdirectory(lwip-2.2.0)
add_subdirectory(lwip_netif/linux_netif)
add_subdirectory(apps)
